﻿using SDF.Core.Infrastructure;
using SDF.Plugin.Misc.SAPAdapter.Models;
using SDF.Plugin.Misc.SAPAdapter.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SDF.Core;

namespace SDF.Plugin.Misc.SAPAdapter.Controllers.Version1
{
    public class TableInfoController:SAPWebApiBase
    {
        ISAPConnectorService _sapService;

        TableInfoController() {
            _sapService = EngineContext.Current.Resolve<ISAPConnectorService>();
        }

        public IEnumerable<TableInfoModel> Post(TableInfoAPIModel model)
        {
            model.NullCheck("model");
            model.SAPInstance.NullOrEmptyCheck("SAPInstance");
            model.TableName.NullOrEmptyCheck("TableName");

            return _sapService.GetTableInfo(model.SAPInstance, model.TableName);
        }
    }
}